#include <iostream>
#include <set>
#include <cstring>
#define MAXN 105
#define MAXM 100005
using namespace std;
int N, M;
int c[MAXN], n[MAXN]; // 面值和个数
int dp[MAXM]; // 前i种面值为j还剩下的i的个数


void solve();
int main() {
    while (cin >> N >> M && N + M != 0) {
        for (int i = 0; i < N; i++) cin >> c[i];
        for (int i = 0; i < N; i++) cin >> n[i];
        memset(dp, -1, sizeof dp);
        solve();
    }
}

void solve() {
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= M; j++) {
            if (dp[j] >= 0) dp[j] = n[i];
            else if (j < c[i] || dp[j - c[i]] <= 0) dp[j] = -1;
            else dp[j] = dp[j - c[i]] - 1;
        }
    }
    int res = 0;
    for (int i = 1; i <= M; i++) res += (dp[i] >= 0);
    cout << res << endl;
}